// 管理页面路由
import admin from '@/views/admin.ejs';

export default function (router) {
    // 判断是否 存在token
    if (!localStorage.getItem("token")) {
        return ;
    }
    router.route("/admin", (req, res, next) => {
        next(admin({
            subRoute: res.subRoute(),
            url: req.url,
            username:localStorage.getItem("username")
        }));

        // 获取 li 按钮 ；
        let lis = document.querySelectorAll(".menu-left li");
        lis.forEach((li, key) => {
            li.onclick = function () {
                if(key==0){
                    router.go("/admin/users");
                }else if(key == 1){
                    router.go("/admin/adv");
                }
            }
        })

    })
}